package com.cskaoyan.service;

import com.cskaoyan.bean.User;
import com.cskaoyan.mapper.UserMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{

    //@Autowired
    //SqlSessionFactory sqlSessionFactory;

    UserMapper userMapper;

    @Override
    public User queryUserById(Integer id) {
        //SqlSession sqlSession = sqlSessionFactory.openSession();
        //UserMapper mapper = sqlSession.getMapper(UserMapper.class);

        return userMapper.selectByPrimaryKey(id);
    }

    public int insertUser(User user){
        //sqlSession = MyBatisUtil.getSqlSession();
        //UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        int i = userMapper.insertUser(user);
        //sqlSession.commit();
        //sqlSession.close();
        return i;
    }
}
